<?php

require_once('constants.php');

// Check if the key is provided
if (!isset($_GET['key']))
{
    exit();
}
$key = $_GET['key'];
if (empty($key))
{
    exit();
}

// Use the key for the folder name to prevent unauthorized use of the proxy.
$foldername = TEMP_PATH . $key . "/";
$respfile = fopen($foldername . RESP_FILE_NAME, "w+");
$resplock = fopen($foldername . RESP_LOCK_FILE_NAME, "w+");
if ($respfile !== FALSE && $resplock !== FALSE)
{
    session_start();
    $_SESSION[FOLDER_NAME_VAR] = $foldername;
    $_SESSION[RESP_LAST_POSITION_VAR] = 0;
    $_SESSION[REQ_FILE_NAME_ARRAY] = array();
}
?>
